let Mock=require('mockjs')
let city=require('./city.json')
let store=require('./store.json')
let menu=require('./menu.json')

//扩展mockjs
Mock.Random.extend({
  phone:function () {
    let phonePrefixs=['182','188','199']//前缀
    return this.pick(phonePrefixs)+Mock.mock(/\d{8}/)
  }
})

Mock.mock('/login',"post",function(options){
  console.log("options");
  console.log(options);
  return {
    status:200,
    msg:"登录成功",
    data:{
      userInfo:Mock.mock({
        'name':'@cname',
        'password':'123456',
        'star|1-20':1,
        'phone':'@phone',
        'common_address':[],
        'avatar':'http://p9.itc.cn/q_70/images03/20210114/84425436f8bd4d389e6dcb2d43fd74da.jpeg'
      })
    }
  }
})

Mock.mock("/api/getVerificationCode","get",{
  status:200,
  msg:"生成成功",
  data:{
    'num|100000-999999':1
  }
})

Mock.mock('/api/labelMap','get',{
  status:0,
  msg:"success",
  data:{
    data:{
      '0':'家',
      '1':'公司',
      '2':'其他',
    }
  }
})

Mock.mock('/api/getCities','get',{
  status:0,
  msg:"success",
  data:{
    cities:city
  }
})

Mock.mock(RegExp('/api/getStore.*'),'get',function(options) {
  console.log(options);
  return store;
})

Mock.mock('/api/getMenu','get',menu)